package com.server.commons.rabbitmq.config;

import com.server.commons.rabbitmq.MyRabbitTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
@Slf4j
public class RabbitConfig {


    @Bean(name = "myRabbitTemplate")
    @Primary
    public MyRabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) {
        MyRabbitTemplate rabbitTemplate = new MyRabbitTemplate(connectionFactory);

        rabbitTemplate.setMandatory(true);
        rabbitTemplate.setUsePublisherConnection(true);
        rabbitTemplate.setUserCorrelationId(true);

        return rabbitTemplate;
    }



}
